// 修改容器样式以适应弹窗
.container {
  height: calc(100vh - 180px); // 适应弹窗高度
  padding: 12px;
  background: #f1f2f6;
  border-radius: 8px;
}

.main {
  height: 100%;
  background: #fff;
  position: relative;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.panel {
  display: flex;
  height: 100%;
  gap: 12px;
}

.tomb-status-group {
  display: flex;
  flex-direction: column;
  gap: 8px; // 增加间距
  padding: 6px; // 添加内边距
  background: #f8f9fa; // 添加浅色背景
  border-radius: 6px; // 圆角
  border: 1px solid #eee; // 添加边框
  margin: 4px 0; // 增加外边距
}

.tomb-status-sub-item {
  display: flex;
  align-items: center;
  gap: 12px; // 增加间距
  padding: 4px 8px; // 添加内边距

  &:hover {
    background: rgba(0, 0, 0, 0.02); // 添加悬停效果
    border-radius: 4px;
  }
}

.group-text {
  margin: 4px 0 4px 4px; // 调整边距
  color: #1890ff; // 使用主题色
  font-weight: 500; // 加粗
  font-size: 14px; // 调整字号
}

.group-divider {
  height: 1px;
  background: #e8e8e8;
  margin: 12px 0; // 增加分隔线上下间距
}

.sidebar {
  width: 220px;
  background: #fff;
  border-radius: 6px;
  border: 1px solid #e8e8e8;
  display: flex;
  flex-direction: column;
  overflow: hidden; // 改为 hidden

  .sidebar-header {
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 500;
    color: #1890ff;
    background: #f8faff;
    border-bottom: 1px solid #e8e8e8;
    position: sticky; // 添加固定定位
    top: 0; // 固定在顶部
    z-index: 10; // 确保在��形控件之上
    padding-left: 24px;
    flex-shrink: 0; // 防止压缩
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;

    &::before {
      content: '';
      position: absolute;
      left: 0;
      top: 50%;
      transform: translateY(-50%);
      width: 3px;
      height: 16px;
      background: #1890ff;
      border-radius: 2px;
      margin-left: 12px;
    }
  }

  :deep(.ant-tree) {
    background: transparent;
    padding: 0 12px;
    overflow-y: auto; // 只树形控件滚动
    flex: 1; // 占据剩余空间

    .ant-tree-node-content-wrapper {
      padding: 0px 8px;
      border-radius: 4px;
      transition: all 0.3s;

      &:hover {
        background: rgba(24, 144, 255, 0.08);
      }

      &.ant-tree-node-selected {
        background: rgba(24, 144, 255, 0.15);
      }
    }
  }
}

.content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.content-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: #fff;
  border-bottom: 1px solid #f0f0f0;
}

.legend-buttons {
  display: flex;
  gap: 8px;
  align-items: center;

  .legend-button {
    height: 32px;
    padding: 0 10px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: 4px;
    border-color: #e8e8e8;
    transition: all 0.3s ease;

    &:hover {
      color: #1890ff;
      border-color: #1890ff;
      background: #f0f7ff;
    }

    .anticon {
      font-size: 14px;

      &:last-child {
        margin-left: 4px;
        font-size: 12px;
      }
    }
  }
}

.action-buttons {
  display: flex;
  gap: 8px;
  align-items: center;

  .ant-btn {
    height: 32px;
    padding: 0 16px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: 4px;
    font-size: 13px;

    &.ant-btn-primary {
      background: #1890ff;
      border-color: #1890ff;

      &:hover {
        background: #40a9ff;
        border-color: #40a9ff;
      }
    }

    .anticon {
      font-size: 14px;
    }
  }
}

// 下拉菜单样式
.legend-menu {
  padding: 4px;
  min-width: 180px;
  border-radius: 4px;
  box-shadow: 0 3px 6px -4px rgba(0, 0, 0, 0.12), 0 6px 16px 0 rgba(0, 0, 0, 0.08), 0 9px 28px 8px rgba(0, 0, 0, 0.05);

  .ant-menu-item {
    padding: 8px 12px;
    margin: 2px 0;
    border-radius: 4px;

    &:hover {
      background: #f5f5f5;
    }
  }

  .tomb-status-item {
    display: flex;
    align-items: center;
    gap: 10px;

    .tomb-status-color {
      width: 40px;
      height: 24px;
      border-radius: 2px;
      border: 1px solid rgba(0, 0, 0, 0.06);
    }

    .tomb-type-color {
      width: 50px;
      height: 40px;
      border-radius: 2px;
      border: 1px solid rgba(0, 0, 0, 0.06);
      overflow: hidden;

      img {
        width: 100%;
        height: 100%;
        object-fit: cover;
      }
    }
  }
}

.stats-section {
  padding: 10px 12px;
  background: #fff;
  border-bottom: 1px solid #f0f0f0;

  .section-content {
    background: #f8faff;
    border-radius: 6px;
    border: 1px solid rgba(24, 144, 255, 0.1);
    padding: 10px;
  }

  .title-area {
    display: flex;
    justify-content: space-between;
    // align-items: center;
    flex-direction: column;
  }

  .title-left {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .collapse-btn {
    padding: 0;
    height: 24px;
    width: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.3s;

    &:hover {
      background: rgba(0, 0, 0, 0.04);
    }

    .anticon {
      font-size: 12px;
      color: #666;
    }
  }

  .stats-title {
    font-size: 15px;
    color: #1890ff;
    font-weight: 600;
    margin: 0;
    padding-left: 12px;
    position: relative;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 300px;
    cursor: pointer;

    &::before {
      content: '';
      position: absolute;
      left: 0;
      top: 50%;
      transform: translateY(-50%);
      width: 3px;
      height: 16px;
      background: #1890ff;
      border-radius: 2px;
    }
  }

  .search-inputs {
    display: flex;
    gap: 6px;
    align-items: center;
    margin-top: 12px;
    justify-content: flex-end;

    .ant-input-search {
      width: 130px;
      .ant-input {
        border-radius: 4px;
      }
    }

    :deep(.ant-select ul) {
      width: var(--ant-select-ul-dropdown-width);
      max-width: var(--ant-select-ul-dropdown-max-width);
    }
  }

  .stats-row {
    transition: all 0.3s ease;
    overflow: hidden;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    background: #fff;
    border-radius: 4px;
    border: 1px solid rgba(24, 144, 255, 0.1);
  }

  .stats-item {
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    font-size: 13px;
    color: #666;

    span {
      font-weight: 500;
    }

    .ant-tag {
      margin: 0;
      font-size: 13px;
      padding: 1px 8px;
      border-radius: 3px;
      line-height: 1.5;
      min-width: 32px;
      text-align: center;
    }
  }

  .stats-divider {
    width: 1px;
    height: 14px;
    background: #e8e8e8;
  }
}

// 更多条件下拉菜单样式
.more-menu {
  padding: 12px;
  min-width: 200px;

  .ant-menu-item {
    padding: 8px;
    height: auto;
    line-height: 1;

    &:hover {
      background: transparent;
    }
  }
}

.list-section {
  flex: 1;
  overflow: hidden; // 改为hidden
  padding: 12px;

  .scroller {
    height: 100%;

    // 添加虚拟滚动相关样式
    :deep(.vue-recycle-scroller__item-wrapper) {
      overflow: visible; // 允许子元素溢出以显示悬浮效果
    }
  }

  .list-row {
    margin: 0;
    // min-height: 200px; // 设置最小高度
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    display: flex;
    align-items: stretch;

    &:last-child {
      margin-bottom: 0;
    }
  }

  .row-divider {
    width: 100%;
    height: 18px;
    background: #f0f0f0;
  }
}

.row-header {
  padding: 12px;
  background: #fafafa;
  border-right: 1px solid #f0f0f0;
  font-size: 14px;
  font-weight: 500;
  color: #666;
  position: relative;
  width: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  writing-mode: vertical-tb; // 改为垂直从上到下
  flex-shrink: 0;
  text-align: center;
  line-height: 1.5;
  letter-spacing: 0; // 移除字间距

  &::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 2px;
    background: rgba(24, 144, 255, 0.2);
    border-radius: 2px 0 0 0;
  }
}

.tomb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 12px;
  padding: 16px;
  background: #fafafa;
  border-radius: 0 8px 8px 0; // 调整圆角
  flex: 1; // 占据剩余空间
}

.loading-mask {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(255, 255, 255, 0.7);
  z-index: 1000;
}

.tomb-status-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  padding: 4px 0;

  &:last-child {
    margin-bottom: 0;
  }
}

.tomb-status-color {
  width: 40px;
  height: 26px;
  border: 1px solid #f0f0f0;
}

.tomb-type-color {
  width: 60px;
  height: 46px;
  border: 1px solid #f0f0f0;
}

// 墓穴样式
.item-box {
  background: #fff;
  border-radius: 8px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  overflow: hidden;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
  border: 1px solid #e8e8e8;
  position: relative; // 添加相对定位

  &:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.08);
    border-color: #1890ff;
    .deceased-name {
      background: rgba(24, 144, 255, 0.05);
    }
  }
}

// 添加选中状态样式
.selected-item-tomb {
  border: 2px solid #1890ff;
  box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.2);
  box-sizing: border-box;

  .tombstone-title {
    background: rgba(24, 144, 255, 0.1);

    > div:first-child {
      color: #1890ff;
    }
  }

  // 选中状态下的悬停效果
  &:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 16px rgba(24, 144, 255, 0.15);
  }

  // 墓碑样式在选中状态下的变化
  .tombstone-box {
    filter: drop-shadow(0 4px 8px rgba(24, 144, 255, 0.2));
  }
}

.selected-item-tomb::after {
  content: '';
  position: absolute;
  right: -2px;
  top: -2px;
  width: 24px;
  height: 24px;
  background: #1890ff;
  border-radius: 0 8px 0 8px;
}

.selected-item-tomb::before {
  content: '✓';
  position: absolute;
  right: 4px;
  top: 2px;
  color: #fff;
  font-size: 14px;
  font-weight: bold;
  z-index: 1;
  font-family: 'Arial', sans-serif;
}

// 优化标题样式
.tombstone-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: linear-gradient(to right, rgba(0, 0, 0, 0.03), rgba(0, 0, 0, 0.06));
  font-size: 14px;
  font-weight: 500;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);

  > div:first-child {
    color: #1a1a1a;
    font-weight: 600;
  }

  > div:last-child {
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.04);
  }
}

// 墓碑基础样式 Mixin
.tombstone-base-style() {
  transition: all 0.3s ease;
  border-color: rgba(0, 0, 0, 0.3);
  background: linear-gradient(to bottom, #ffffff, #f8f9fa);

  &[style*='background: rgb(0, 0, 0)'],
  &[style*='background:#000'] {
    background: linear-gradient(#000) !important;
    border-color: #000;
  }
}

// 墓碑组件式
.tombstone-box {
  position: relative;
  transition: all 0.3s ease;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));

  &:hover {
    transform: scale(1.08);
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.15));
  }
}

// 墓碑各部分样���
.tombstone-circle {
  .tombstone-base-style();
  width: 32px;
  height: 18px;
  border-top-right-radius: 32px;
  border-top-left-radius: 32px;
  border: 1.5px solid;
  border-bottom: 0;
  position: relative;
  z-index: 2;
}

.tombstone-rectangle {
  .tombstone-base-style();
  width: 32px;
  height: 42px;
  border: 1.5px solid;
  border-top: none;
  position: relative;
  z-index: 2;
}

.tombstone-bottom-rectangle {
  .tombstone-base-style();
  width: 44px;
  height: 28px;
  border-top-right-radius: 32px;
  border-top-left-radius: 32px;
  border: 1.5px solid;
  margin-left: -6px;
  margin-top: -22px;
  position: relative;
  z-index: 1;
}

// 墓碑容器基础样式
.tombstone-container() {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 8px 0;
  position: relative;
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0.8), rgba(255, 255, 255, 0.4));
  height: 90px; // 统一所有类型的高
  box-sizing: border-box;

  &::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 10%;
    right: 10%;
    height: 1px;
    background: linear-gradient(to right, transparent, rgba(0, 0, 0, 0.05), transparent);
  }
}

// 单穴墓型
.tombstone-item {
  margin-left: 6px;
  .tombstone-container();
}

// 双穴墓型
.tombstone-item-2 {
  .tombstone-container();
  gap: 12px;
  margin-left: 6px;
}

// 多穴墓型
.tombstone-item-4 {
  .tombstone-container();
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(2, 1fr);
  padding: 2px;
  gap: 0;
  align-items: center;
  justify-items: center;
  background: rgba(0, 0, 0, 0.02);
  border-radius: 8px;

  .tombstone-box {
    position: relative;
    margin: 0;
    transform-origin: center center;
    scale: 0.8;

    // 添加名称显示样式
    .tomb-name {
      position: absolute;
      top: -20px;
      left: 50%;
      transform: translateX(-50%);
      background: rgba(24, 144, 255, 0.1);
      padding: 2px 6px;
      border-radius: 4px;
      font-size: 12px;
      color: #1890ff;
      white-space: nowrap;
      max-width: 100px;
      overflow: hidden;
      text-overflow: ellipsis;
      z-index: 3;
      text-align: center;
    }

    // 左侧两个墓穴
    &:nth-child(1) {
      margin-bottom: -30px;
      margin-right: -15px;
    }

    &:nth-child(3) {
      margin-top: -30px;
    }

    // 右侧两个墓穴
    &:nth-child(2) {
      margin-bottom: -30px;
      margin-left: -15px;
    }

    &:nth-child(4) {
      margin-top: -30px;
    }

    &:hover {
      z-index: 10;
      .tomb-name {
        background: rgba(24, 144, 255, 0.2);
      }
    }
  }
}

// 优化图例样式
.legend-info {
  padding: 20px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);

  .ant-card {
    border-radius: 6px;
    transition: all 0.3s ease;

    &:hover {
      box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    }

    .ant-card-head {
      padding: 0 20px;
      min-height: 48px;
      font-weight: 600;
      color: #1a1a1a;
    }

    .ant-card-body {
      padding: 20px;
    }
  }
}

// 添加响应式布局支持
@media screen and (max-width: 1400px) {
  .list-section {
    .row-header {
      width: 35px;
      font-size: 13px;
      padding: 10px;
    }
  }

  .tomb-grid {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
    padding: 12px;
  }

  .row-header {
    padding: 10px 16px;
    font-size: 14px;
  }

  .tombstone-item-4 {
    .tombstone-box {
      scale: 0.75; // 中等屏幕下稍微缩小

      &:nth-child(1) {
        margin-bottom: -45px;
        margin-right: -12px;
      }

      &:nth-child(3) {
        margin-top: -18px;
        margin-right: -12px;
      }

      &:nth-child(2) {
        margin-bottom: -45px;
        margin-left: -12px;
      }

      &:nth-child(4) {
        margin-top: -18px;
        margin-left: -12px;
      }
    }
  }
}

@media screen and (max-width: 768px) {
  .list-section {
    .row-header {
      width: 100%;
      height: 35px;
      writing-mode: horizontal-tb;
      justify-content: flex-start;
      padding: 8px 12px;

      &::before {
        width: 100%;
        height: 2px;
        top: auto;
        bottom: 0;
      }
    }

    .tomb-grid {
      padding: 10px;
      border-radius: 0 0 8px 8px;
    }
  }

  .tomb-grid {
    padding: 10px;
  }

  .tombstone-title {
    padding: 6px 10px;

    > div:first-child {
      font-size: 13px;
    }

    > div:last-child {
      font-size: 11px;
      padding: 1px 6px;
    }
  }

  .tombstone-item-4 {
    .tombstone-box {
      scale: 0.7; // 小屏��下再缩小一点

      &:nth-child(1) {
        margin-bottom: -40px;
        margin-right: -10px;
      }

      &:nth-child(3) {
        margin-top: -16px;
        margin-right: -10px;
      }

      &:nth-child(2) {
        margin-bottom: -40px;
        margin-left: -10px;
      }

      &:nth-child(4) {
        margin-top: -16px;
        margin-left: -10px;
      }
    }
  }

  .tombstone-item,
  .tombstone-item-2 {
    min-height: 84px;
  }

  .tombstone-container() {
    height: 100px;
  }
}

// 添加逝者姓名样式
.deceased-name {
  padding: 4px 12px;
  font-size: 12px;
  color: #1890ff;
  background: rgba(0, 0, 0, 0.02);
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
  font-weight: 500;
  transition: all 0.3s ease;

  .name-text {
    display: flex;
    align-items: center;
    gap: 8px;

    span {
      display: inline-flex;
      align-items: center;
      gap: 4px;

      .anticon {
        font-size: 12px;
        opacity: 0.7;
      }
    }

    .relative-name {
      color: #722ed1; // 家属名字使用不同颜色
      &::before {
        content: '|';
        margin-right: 8px;
        color: #d9d9d9;
      }
    }
  }

  &:hover {
    background: rgba(24, 144, 255, 0.1);
  }
}

.tomb-modal {
  :deep(.ant-modal-body) {
    padding: 0;
  }
}

// 添加选中状态的动画
@keyframes selectedPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(24, 144, 255, 0.4);
  }
  70% {
    box-shadow: 0 0 0 6px rgba(24, 144, 255, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(24, 144, 255, 0);
  }
}

.item-box.selected {
  animation: selectedPulse 2s infinite;
}

// 优化 tooltip 样式
.tomb-info-tooltip {
  padding: 8px;
  max-width: 300px;

  .info-row {
    margin-bottom: 6px;
    display: flex;
    gap: 8px;
    align-items: flex-start;

    &:last-child {
      margin-bottom: 0;
    }

    .label {
      color: rgba(255, 255, 255, 0.85);
      font-weight: 500;
      min-width: 70px;
      flex-shrink: 0;
    }
  }
}

// 详情弹窗专属样式
.tomb-detail-dialog {
  :deep(.ant-modal-body) {
    background: #f5f7fa;
    // padding: 20px;
  }

  :deep(.ant-modal-footer) {
    border-top: none;
    padding: 16px 24px;
  }

  .tomb-detail-wrapper {
    .detail-section {
      background: #fff;
      border-radius: 8px;
      margin-bottom: 16px;
      box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
      overflow: hidden;

      &:last-child {
        margin-bottom: 0;
      }

      .section-header {
        padding: 16px;
        border-bottom: 1px solid #f0f0f0;
        display: flex;
        align-items: center;
        gap: 8px;
        background: #fafafa;

        .header-icon {
          font-size: 18px;
        }

        .header-title {
          color: #1890ff;
          font-size: 15px;
          font-weight: 600;
        }
      }

      :deep(.ant-descriptions) {
        padding: 16px;

        .ant-descriptions-item-label {
          background: #fafafa;
          color: #666;
          font-weight: 500;
        }

        .ant-descriptions-item-content {
          color: #333;
        }
      }
    }

    .deceased-grid {
      display: grid;
      grid-template-columns: repeat(2, 1fr);
      gap: 16px;
      padding: 16px;
    }

    .deceased-card {
      background: #fff;
      border: 1px solid #f0f0f0;
      border-radius: 8px;
      overflow: hidden;
      transition: all 0.3s ease;

      &:hover {
        box-shadow: 0 4px 12px rgba(24, 144, 255, 0.1);
        border-color: #1890ff;
        transform: translateY(-2px);
      }

      .card-header {
        padding: 12px 16px;
        background: #f8faff;
        border-bottom: 1px solid #f0f0f0;
        display: flex;
        justify-content: space-between;
        align-items: center;

        .card-title {
          color: #666;
          font-size: 13px;
        }

        .card-name {
          color: #1890ff;
          font-weight: 600;
          font-size: 14px;
        }
      }

      .card-content {
        padding: 12px 16px;

        .info-row {
          display: flex;
          margin-bottom: 8px;
          font-size: 13px;

          &:last-child {
            margin-bottom: 0;
          }

          .label {
            width: 90px;
            color: #666;
            flex-shrink: 0;
          }
        }
      }
    }

    .relative-card {
      padding: 16px;

      .info-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;

        .info-item {
          display: flex;
          gap: 8px;
          font-size: 13px;

          &.full-width {
            grid-column: span 2;
          }

          .label {
            color: #666;
            width: 80px;
            flex-shrink: 0;
          }
        }
      }
    }
  }

  // 价格文本样式
  .price-text {
    color: #f5222d;
    font-weight: 500;
  }

  // Badge 优化
  :deep(.ant-badge-status) {
    display: inline-flex;
    align-items: center;

    .ant-badge-status-dot {
      width: 8px;
      height: 8px;
    }

    .ant-badge-status-text {
      margin-left: 8px;
      font-size: 14px;
    }
  }
}
